<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<%@ include file="/WEB-INF/pages/weixin/include/title.jsp"%>
    <%@ include file="/WEB-INF/pages/weixin/include/include.jsp"%>
    
	<script src="${root}/res/jsLib/jquery/jquery-1.11.1.min.js"></script>
	<script src="${root}/res/jsLib/Validform_v5.3.2_min.js"></script>
	<script src="${root}/res/jsLib/ValidformExp.js"></script>
    
    <script type="text/javascript">
    	var vf;
	    $(function(){
	    	
	    	vf = $("#userForm").validform();
	    	
	    	wxUtils.loadDicData({
	    		urlFun:function(){
	    			return JSON.stringify({"method":"area1",'id':'441600'});
	    		},
	    		showFun:function(data){
	    			var area2 = $("#userForm").find("select[name='orgArea2']");
	    			area2.empty();
	    			area2.append("<option value=''>--请选择--</option>");
	    			for(var i=0; i<data.datalist.length; i++){
	    				var trem = data.datalist[i];
	    				area2.append("<option value='"+trem['AREA_CODE']+"'>"+trem['AREA_NAME']+"</option>");
	    			}
	    		}
	    	});
	    	
	    	industry1();
	    	
	    	wxUtils.initSearchBar();
	    	wxUtils.iniScrollBar();
	    	
	    	$("#submitBtn").bind("click",function(){
	    		if(vf.check()){
	    			wxUtils.showToast("正在提交");
		    		$.post(wxUtils.ctx+"/weixin/enterprise/register.do",$("#userForm").serialize(),function(data){
		    			wxUtils.closeToast();
		    			if(data.success){
		    				wxUtils.msg(data.msg,1,function(){
		    					window.location.href = wxUtils.ctx + "/weixin/login.do"; 
		    				});
		    			}else{
		    				wxUtils.msg(data.msg,2);
		    			}
		    		},'json');
	    		}
	    	});
	    });
	    
	    function industry1(){
	    	var form = $("#userForm");
	    	var industry = form.find("select[name='industry1']");
	    	if(industry.length>0){
	    		industry.empty();
	    		form.find("select[name='industry2']").empty();
	    		form.find("select[name='industry3']").empty();
	    		form.find("select[name='industry4']").empty();
		    	wxUtils.loadDicData({
		    		urlFun:function(){
		    			return JSON.stringify({"method":"industry"});
		    		},
		    		showFun:function(data){
		    			industry.append("<option value=''>--请选择--</option>");
		    			for(var i=0; i<data.datalist.length; i++){
		    				var trem = data.datalist[i];
		    				industry.append("<option value='"+trem['INDUSTRY_CODE']+"'>"+trem['INDUSTRY_NAME']+"</option>");
		    			}
		    		}
		    	});
	    	}
	    }
	    
	    function industry234(i,parent){
	    	var form = $("#userForm");
	    	var id = $(parent).val();
	    	var industry = form.find("select[name='industry"+i+"']");
	    	if(industry.length>0 && $.trim(id)!=''){
	    		industry.empty();
	    		if(i<3){
	    			var temp = form.find("select[name='industry3']")
	    			temp.empty();
	    			temp.append("<option value=''>--请选择--</option>");
	    		}
	    		if(i<4){
	    			var temp = form.find("select[name='industry4']")
	    			temp.empty();
	    			temp.append("<option value=''>--请选择--</option>");
	    		}
	    		wxUtils.loadDicData({
		    		urlFun:function(){
		    			return JSON.stringify({"method":"industry234","id":id});
		    		},
		    		showFun:function(data){
		    			industry.append("<option value=''>--请选择--</option>");
		    			for(var i=0; i<data.datalist.length; i++){
		    				var trem = data.datalist[i];
		    				industry.append("<option value='"+trem['INDUSTRY_CODE']+"'>"+trem['INDUSTRY_NAME']+"</option>");
		    			}
		    		}
		    	});
	    	}else{
	    		industry.empty();
	    	}
	    }
	</script>
</head>
<body>
<div class="page" style="height: 100%;">
    <div class="page__bd">
    	<div class="weui-tab__panel detail_panel" style="display: none;"></div>
        <div class="weui-tab list_panel">
        	<div class="weui-navbar" position="top">
                <div class="weui-navbar__item" onclick="wxUtils.linkClick('/weixin/personal.do');">个人用户注册</div>
                <div class="weui-navbar__item weui-bar__item_on">企业用户注册</div>
            </div>
            <div class="weui-tab__panel">
            	<div class="weui-panel weui-panel_access" position="center">
            	<form id="userForm">
				    <div class="weui-cells weui-cells_form">
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
			                <div class="weui-cell__bd">
			                    <input class="weui-input" type="text" name="username" dataType="*4-16" placeholder="请输入用户名"/>
			                </div>
			            </div>
			            
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
			                <div class="weui-cell__bd">
			                    <input class="weui-input" type="password" name="password" dataType="*4-36"  placeholder="请输入密码"/>
			                </div>
			            </div>
			            
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">确认密码</label></div>
			                <div class="weui-cell__bd">
			                    <input class="weui-input" type="password" dataType="*" recheck="password" placeholder="请再次输入密码"/>
			                </div>
			            </div>
			            
			             <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">E-mail</label></div>
			                <div class="weui-cell__bd">
			                    <input class="weui-input" type="text" name="email" dataType="e" placeholder="请输入E-mail"/>
			                </div>
			            </div>
			            
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">企业名称</label></div>
			                <div class="weui-cell__bd">
			                    <input class="weui-input" type="text" name="orgName" dataType="*1-150" placeholder="请输入企业名称"/>
			                </div>
			            </div>
			            
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">所属地区</label></div>
			                <div class="weui-cell__bd">
			                	<input type="hidden" name="orgArea1" value="441600"/>
			                    <select class="weui-select" name="orgArea2" dataType="*" ></select>
			                </div>
			            </div>
			            
			            <div class="weui-cell">
			                <div class="weui-cell__hd"><label class="weui-label">所属行业</label></div>
			                <div class="weui-cell__bd">
			                    <select class="weui-select" name="industry1" dataType="*" onchange="industry234(2,this)"><option value="">--请选择--</option></select>
			                    <select class="weui-select" name="industry2" dataType="*" onchange="industry234(3,this)"><option value="">--请选择--</option></select>
			                    <select class="weui-select" name="industry3" dataType="*" onchange="industry234(4,this)"><option value="">--请选择--</option></select>
			                    <select class="weui-select" name="industry4" dataType="*"><option value="">--请选择--</option></select>
			                </div>
			            </div>
			        </div>
			        <div class="weui-btn-area">
			            <a id="submitBtn" class="weui-btn weui-btn_primary" href="javascript:void(0);" >完成注册</a>
			            <a href="javascript:wxUtils.linkClick('/weixin/bind.do');" class="weui-btn weui-btn_default">已有账号</a>
			        </div>
			    </form>
				</div>
            </div>
        </div>
    </div>
	<jsp:include page="/WEB-INF/pages/weixin/bottom.jsp?menu=4"></jsp:include>
</div>
</body>
</html>

